﻿#include "TcpCodec_Transmit.h"

#include "TcpCodec.h"

TcpCodec_Transmit::TcpCodec_Transmit()
{
  transmitResult.append(QStringLiteral("指令下发成功"));
  transmitResult.append(QStringLiteral("正在下发指令"));
  transmitResult.append(QStringLiteral("指令下发失败，前一条指令正在下发"));
  transmitResult.append(QStringLiteral("指令下发失败，目标设备已离线"));
  transmitResult.append(QStringLiteral("指令下发失败，指令下发超时"));
  transmitResult.append(QStringLiteral("指令下发失败，指令数据错误"));
}

TcpCodec_Transmit::~TcpCodec_Transmit()
{

}

void TcpCodec_Transmit::decode(DataPackage_TcpCodec* dataPackageInfo_User)
{
  emit signal_result((uchar)dataPackageInfo_User->getData().at(0));
}

QString TcpCodec_Transmit::getResultMessage(uchar type)
{
  return transmitResult.at(type);
}

TcpCodec* TcpCodec_Transmit::getTcpCodec()const
{
  return tcpCodec;
}

TcpCodec_Transmit* TcpCodec_Transmit::setTcpCodec(TcpCodec* const tcpCodec)
{
  this->tcpCodec=tcpCodec;
  tcpCodec->addToCodecMap(TcpCodec_Transmit::Transmit,this);
  printInjection(this,tcpCodec);
  return this;
}

void TcpCodec_Transmit::objectAutoInjection(QHash<QString,QObject*>* objMap)
{
  setTcpCodec(getObjFromMap<TcpCodec>(objMap));
}
